package com.hp_dzzl.mixin.mcr.bossrise.entity;


import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.unusual.blockfactorysbosses.entity.InfernalDragonEntity;
import net.unusual.blockfactorysbosses.procedures.InfernalDragonEntityIsHurtProcedure;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;

@Mixin(
        value = InfernalDragonEntity.class,
        remap = false
)
public abstract class InfernalDragonEntityMixin extends LivingEntity {

    protected InfernalDragonEntityMixin(EntityType<? extends LivingEntity> p_20966_, Level p_20967_) {
        super(p_20966_, p_20967_);
    }

    /**
     * @author 你的名字
     * @reason 取消所有伤害免疫，同时保留原受伤逻辑
     */
    @Overwrite
    public boolean hurt(DamageSource damagesource, float amount) {
        // 1. 转换为原实体并保留受伤触发逻辑
        InfernalDragonEntity thisDragon = (InfernalDragonEntity) (Object) this;
        Level world = thisDragon.level();
        Entity sourceentity = damagesource.getEntity();
        InfernalDragonEntityIsHurtProcedure.execute(world, thisDragon);

        // 2. 调用父类默认伤害处理，跳过原免疫判断
        return super.hurt(damagesource, amount);
    }
}